<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\Resource;

class AdminResource extends Resource
{
    use BaseResource;
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'id' => (int) $this->id,
            'username' => (string) $this->username,
            'type'=>(string)$this->type,
            'name' => (string) $this->name,
            'sex' => (string) $this->sex,
            'school_id' => (string) $this->school_id,
            'api_token'=> (string) $this->api_token,
//            'permissions' => $this->when($this->hasInclude($request, 'profile'), $this->getPermissions())
        ];
    }

//    public function getPermissions()
//    {
//        $permissionList = [];
//        foreach ($this->roles as $role) {
//            foreach ($role->perms as $permission) {
//                $permissionList[] = $permission->name;
//            }
//        }
//        return $permissionList;
//    }
}
